package cn.gjculture.shopping.api.dao;

import cn.gjculture.shopping.api.entity.Merchant;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface MerchantDao {

    @Insert("insert into merchant(merchantId,sonMerNo,merType,name,phone,idCardNo,status,insertTime,updateTime,belongId,bank,bankCardNo,belongType) " +
            "values(#{merchantId},#{sonMerNo},#{merType},#{name},#{phone},#{idCardNo},#{status},#{insertTime},#{updateTime},#{belongId},#{bank},#{bankCardNo},#{belongType})")
    int save(Merchant mer);


    @Update("update merchant set sonMerNo=#{sonMerNo}, status=#{status},updateTime=#{updateTime} where merchantId=#{merchantId}")
    int updateMerNoAndStauts(Merchant mer);

    @Select("select * from merchant where phone=#{phone}")
    Merchant queryByPhone(String phone);

    @Select("select * from merchant where belongId=#{id}")
    Merchant queryByBelongId(String id);

    @Select("select * from merchant order by updateTime")
    List<Merchant> query();
    @Select("select * from merchant where merchantId=#{merchantId}")
    Merchant queryById(String merchantId);

    @Select("select merchantId,name from merchant where belongId='system'")
    List<Merchant> querySystem();
}
